<!DOCTYPE html>
<html lang="cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button type="button" id="btn1">按钮1</button>
    <button type="button" id="btn2">按钮2</button>
    <p>陆梓峰 24510206097</p>
</body>

</html>
<script>
    let btn1 = document.getElementById("btn1");

    btn1.onclick = function() {
        alert("匿名函数绑定btn1");
    };
    let btn2 = document.getElementById("btn2");

    btn2.addEventListener("click", function() {
        alert("匿名函数绑定btn2");
    });

    // function clkBtn1() {
    // alert("具名btn1");
    // }
    function clkBtn2() {
        alert("事件监听btn2");
    }

    (function() {
        alert("匿名函数直接调用")
    })();

    (function() {
        console.log("匿名函数直接调用，显示在控制台");
    })();
</script>